package cn.lger.icollege.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.*;

import javax.persistence.*;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

/**
 * Code that Changed the World
 * Pro said
 * Created by Pro on 2018-04-14.
 */
@Entity
//@Data
@Setter
@Getter
@NoArgsConstructor
public class Classroom implements Serializable {

    @Id
    private Long classId;

    @Column(length = 60, nullable = false, unique = true)
    private String className; //班级名 15商软2班

    @OneToMany(cascade = CascadeType.REMOVE, mappedBy = "classroom")
    @JsonIgnore
    private Set<Student> students;

    @ManyToMany
    @JsonIgnore
    private Set<Teacher> teachers;

    @OneToMany(cascade = CascadeType.REMOVE, mappedBy = "classroom")
    @JsonIgnore
    private Set<Notice> notices;

    @OneToMany(cascade = CascadeType.REMOVE, mappedBy = "classroom")
    @JsonIgnore
    private Set<AttendanceRecord> attendanceRecords;

    public Classroom(Long classId, String className) {
        this.classId = classId;
        this.className = className;
    }

    public Classroom(Long classId) {
        this.classId = classId;
    }

//    public Set<Student> getStudents() {
//        return students == null?new HashSet<Student>():this.students;
//    }
//
//    public Set<Teacher> getTeachers() {
//        return teachers == null?new HashSet<Teacher>():this.teachers;
//    }
}
